Skip to content

Add TZ data to PHP config#541

Open
otte845 wants to merge 1 commit into
hassio-addons:mainfrom
otte845:main
Open

Add TZ data to PHP config#541
otte845 wants to merge 1 commit into
hassio-addons:mainfrom
otte845:main

Conversation

@otte845

@otte845 otte845 commented May 8, 2026

Copy link
Copy Markdown

Proposed Changes

Writes the TZ environment variable on the PHP config directory as is used by grocy

Related Issues

Solves the following issues:

#375
#362
#274

Summary by CodeRabbit

  • New Features
    • Added support for customizing the PHP runtime timezone through environment variable configuration.

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The pull request adds PHP timezone configuration to the Dockerfile. A RUN command generates a PHP ini file that sets the date.timezone directive from the TZ environment variable, ensuring the PHP runtime respects the configured timezone.

Changes

Timezone Configuration

Layer / File(s) Summary
PHP Runtime Configuration
grocy/Dockerfile
RUN command writes /etc/php85/conf.d/50-tzone.ini to set date.timezone from ${TZ} environment variable for PHP 8.5.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A tiny change hops through the file,
Setting timezones with timely style, 🐰
PHP now knows where and when,
The TZ variable helps again! ⏰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding timezone (TZ) data to PHP configuration via a new PHP ini file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
grocy/Dockerfile (1)

74-74: 💤 Low value

Nitpick: Remove trailing space from comment.

The comment has a trailing space.

✨ Proposed fix
-# Set Timezone for PHP runtime 
+# Set Timezone for PHP runtime
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@grocy/Dockerfile` at line 74, Remove the trailing space at the end of the
Dockerfile comment "# Set Timezone for PHP runtime " so it becomes "# Set
Timezone for PHP runtime" — edit the comment line in grocy/Dockerfile to trim
the trailing whitespace.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@grocy/Dockerfile`:
- Around line 74-76: Remove the broken Dockerfile RUN that uses single quotes to
write "${TZ}" (it prevents shell expansion) and instead configure PHP timezone
at container startup in the init-grocy/run oneshot s6 service; specifically,
delete the printf RUN from the Dockerfile and add startup logic in
init-grocy/run (before the directory-existence check) that logs a debug message
and writes a PHP ini file setting date.timezone using the runtime TZ environment
variable with a sensible default (e.g., UTC).

---

Nitpick comments:
In `@grocy/Dockerfile`:
- Line 74: Remove the trailing space at the end of the Dockerfile comment "# Set
Timezone for PHP runtime " so it becomes "# Set Timezone for PHP runtime" — edit
the comment line in grocy/Dockerfile to trim the trailing whitespace.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d031d96-f640-4b1e-a4f4-d8849be26ad8

📥 Commits

Reviewing files that changed from the base of the PR and between 9fd315f and ede1cee.

📒 Files selected for processing (1)
  • grocy/Dockerfile

Comment thread grocy/Dockerfile
Comment on lines +74 to +76
# Set Timezone for PHP runtime
RUN printf '[PHP]\ndate.timezone = "${TZ}"\n' > /etc/php85/conf.d/50-tzone.ini

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for existing init/entrypoint scripts where runtime config should be added
fd -t f -e sh -e bash . rootfs/etc

Repository: hassio-addons/app-grocy

Length of output: 165


🏁 Script executed:

#!/bin/bash
# Explore repository structure
echo "=== Repository structure ==="
git ls-files | head -30
echo ""
echo "=== Check for rootfs directory ==="
ls -la | grep -E '^d' | head -20
echo ""
echo "=== Search for init, docker-entrypoint, or startup scripts ==="
fd -t f \( -name "entrypoint*" -o -name "init*" -o -name "startup*" \) 
echo ""
echo "=== Directory tree of grocy folder ==="
fd -t d . grocy | head -20

Repository: hassio-addons/app-grocy

Length of output: 2338


🏁 Script executed:

#!/bin/bash
# Read the full Dockerfile to understand context
echo "=== Dockerfile around lines 74-76 ==="
cat -n grocy/Dockerfile | sed -n '65,85p'
echo ""
echo "=== Check init-grocy service directory ==="
fd -t f . grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy
echo ""
echo "=== Check for any existing PHP config files in rootfs ==="
fd -t f . grocy/rootfs/etc/php85/
echo ""
echo "=== Search for any timezone references in the codebase ==="
rg -i "timezone|TZ" grocy/

Repository: hassio-addons/app-grocy

Length of output: 1321


🏁 Script executed:

#!/bin/bash
# Check the init-grocy run script
echo "=== init-grocy/run script ==="
cat -n grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/run
echo ""
echo "=== Existing PHP config (99-grocy.ini) ==="
cat -n grocy/rootfs/etc/php85/conf.d/99-grocy.ini
echo ""
echo "=== Check what type of service init-grocy is ==="
cat grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/type

Repository: hassio-addons/app-grocy

Length of output: 1962


🏁 Script executed:

#!/bin/bash
# Check Home Assistant addon documentation patterns
echo "=== Check config.yaml for TZ environment variable ==="
cat -n grocy/config.yaml
echo ""
echo "=== Check build.yaml ==="
cat -n grocy/build.yaml

Repository: hassio-addons/app-grocy

Length of output: 3372


Critical: Variable substitution won't work—feature is broken.

The single quotes in the printf command prevent shell expansion, so the literal string "${TZ}" will be written to the PHP ini file. Additionally, TZ is not defined as a build ARG, so this configuration cannot access runtime environment variables.

This addon uses s6-overlay service management. The correct approach is to configure the timezone at container startup in the init-grocy/run script (a oneshot s6-overlay service), which has access to the runtime TZ environment variable from Home Assistant:

🔧 Recommended fix
  1. Remove lines 74-76 from the Dockerfile (the broken RUN command)

  2. Add timezone configuration to grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/run before the existing logic:

# After the shebang and comments, before the directory existence check:

# Configure PHP timezone from Home Assistant runtime
bashio::log.debug "Configuring PHP timezone..."
printf '[PHP]\ndate.timezone = %s\n' "${TZ:-UTC}" > /etc/php85/conf.d/50-tzone.ini

This way, the timezone is configured at container startup using the TZ environment variable provided by Home Assistant, and users can change it without rebuilding the image.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@grocy/Dockerfile` around lines 74 - 76, Remove the broken Dockerfile RUN that
uses single quotes to write "${TZ}" (it prevents shell expansion) and instead
configure PHP timezone at container startup in the init-grocy/run oneshot s6
service; specifically, delete the printf RUN from the Dockerfile and add startup
logic in init-grocy/run (before the directory-existence check) that logs a debug
message and writes a PHP ini file setting date.timezone using the runtime TZ
environment variable with a sensible default (e.g., UTC).

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions Bot added the stale There has not been activity on this issue or PR for quite some time. label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale There has not been activity on this issue or PR for quite some time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant